package com.jiazhong.mingxing.project.bookstore.front.listener;

import com.jiazhong.mingxing.project.bookstore.commons.mapper.OrderMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
@Slf4j
// 撤销订单
@Component
@RocketMQMessageListener(consumerGroup = "abc1",topic = "order",selectorExpression = "refund",messageModel = MessageModel.BROADCASTING)
public class RefundOrderListener implements RocketMQListener<String> {
    @Resource
    private OrderMapper orderMapper;

    @Override
    public void onMessage(String s) {
        log.info("开始执行撤销订单操作");
        String orderId = s.split(",")[0];
        orderMapper.deleteById(orderId);
    }
}
